package cn.iocoder.yudao.module.api.pay.transfer.enums;

import cn.iocoder.yudao.framework.business.basic.enums.EnumValuable;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * @author jason
 */
@Getter
@AllArgsConstructor
public enum UnifiedTransferStatusEnum implements EnumValuable {

    WAITING(0, "等待转账"),
    DEALING(10, "转账进行中"), // 转账到银行卡，会有T+0、T+1 等到账的情况
    SUCCESS(20, "转账成功"),
    CLOSED(30, "转账失败"),
    ;

    @EnumValue
    private final Integer value;
    private final String name;

    @Override
    public String toString() {
        return new ViewObject(value, name).toString();
    }

    public static boolean isSuccess(Integer status) {
        return Objects.equals(status, SUCCESS.getValue());
    }

    public static boolean isClosed(Integer status) {
        return Objects.equals(status, CLOSED.getValue());
    }

    public static boolean isWaiting(Integer status) {
        return Objects.equals(status, WAITING.getValue());
    }

    public static boolean isDealing(Integer status) {
        return Objects.equals(status, DEALING.getValue());
    }

    /**
     * 是否处于待转账或者转账中的状态
     *
     * @param status 状态
     */
    public static boolean isPending(Integer status) {
        return Objects.equals(status, WAITING.getValue()) || Objects.equals(status, DEALING.getValue());
    }

}
